package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.StrategyCatalog;
import cn.wolfcode.luowowo.article.mapper.StrategyCatalogMapper;
import cn.wolfcode.luowowo.article.service.IStrategyCatalogService;
import cn.wolfcode.luowowo.common.query.StrategyCatalogQuery;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class StrategyCatalogServiceImpl implements IStrategyCatalogService {

    @Autowired
    private StrategyCatalogMapper strategyCatalogMapper;

    public PageInfo query(StrategyCatalogQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        List<StrategyCatalog> list = strategyCatalogMapper.selectForList(qo);
        return new PageInfo(list);
    }

    public List<StrategyCatalog> list() {
        return strategyCatalogMapper.selectAll();
    }

    public void saveOrUpdate(StrategyCatalog catalog) {
        if (catalog.getId() != null) {
            strategyCatalogMapper.updateByPrimaryKey(catalog);
        } else {

            strategyCatalogMapper.insert(catalog);
        }
    }

    public List<StrategyCatalog> listByDestId(Long id) {
        return strategyCatalogMapper.selectByDestId(id);
    }
}
